package com.example.file_explorer.result;


import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;


    /**成功且带数据**/
    public static <T> Result<T> success(T data) {
        return new Result<>(Code.SUCCESS.getCode(), "响应成功", data);
    }
    /**成功但不带数据**/
    public static <T> Result<T> success(){
        return success(null);
    }
    /**失败**/
    public static <T> Result<T> error(int code, String message) {
        return new Result<T>(code, message, null);
    }
}